home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / xpinstall / nsXPITriggerInfo.h < prev   
C/C++ Source or Header  |  2006-05-08  |  5KB  |  148 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is Mozilla Communicator client code, released
  16.  * March 31, 1998.
  17.  *
  18.  * The Initial Developer of the Original Code is
  19.  * Netscape Communications Corporation.
  20.  * Portions created by the Initial Developer are Copyright (C) 1998-1999
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *   Daniel Veditz <dveditz@netscape.com>
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  28.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the MPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the MPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK ***** */
  39.  
  40. #ifndef nsXPITriggerInfo_h
  41. #define nsXPITriggerInfo_h
  42.  
  43. #include "nsString.h"
  44. #include "nsVoidArray.h"
  45. #include "nsCOMPtr.h"
  46. #include "nsISupportsUtils.h"
  47. #include "nsIFileSpec.h"
  48. #include "nsILocalFile.h"
  49. #include "nsIOutputStream.h"
  50. #include "jsapi.h"
  51. #include "prthread.h"
  52. #include "plevent.h"
  53. #include "nsIXPConnect.h"
  54. #include "nsICryptoHash.h"
  55. #include "nsIPrincipal.h"
  56.  
  57. typedef struct XPITriggerEvent {
  58.     PLEvent     e;
  59.     nsString    URL;
  60.     PRInt32     status;
  61.     JSContext*  cx;
  62.     jsval       global;
  63.     jsval       cbval;
  64.     nsCOMPtr<nsISupports> ref;
  65.     nsCOMPtr<nsIPrincipal> princ;
  66. } XPITriggerEvent;
  67.  
  68.  
  69.  
  70. class nsXPITriggerItem
  71. {
  72.   public:
  73.     nsXPITriggerItem( const PRUnichar* name,
  74.                       const PRUnichar* URL,
  75.                       const PRUnichar* iconURL,
  76.                       const char* hash = nsnull,
  77.                       PRInt32 flags = 0);
  78.     ~nsXPITriggerItem();
  79.  
  80.     nsString    mName;
  81.     nsString    mURL;
  82.     nsString    mIconURL;
  83.     nsString    mArguments;
  84.     nsString    mCertName;
  85.  
  86.     PRBool      mHashFound; // this flag indicates that we found _some_ hash info in the trigger
  87.     nsCString   mHash;
  88.     nsCOMPtr<nsICryptoHash> mHasher;
  89.     PRInt32     mFlags;
  90.  
  91.     nsCOMPtr<nsILocalFile>      mFile;
  92.     nsCOMPtr<nsIOutputStream>   mOutStream;
  93.     nsCOMPtr<nsIPrincipal>      mPrincipal;
  94.  
  95.     void    SetPrincipal(nsIPrincipal* aPrincipal);
  96.  
  97.     PRBool  IsFileURL() { return StringBeginsWith(mURL, NS_LITERAL_STRING("file:/")); }
  98.     PRBool  IsRelativeURL();
  99.  
  100.     const PRUnichar* GetSafeURLString();
  101.  
  102.   private:
  103.     //-- prevent inadvertent copies and assignments
  104.     nsXPITriggerItem& operator=(const nsXPITriggerItem& rhs);
  105.     nsXPITriggerItem(const nsXPITriggerItem& rhs);
  106.  
  107.     nsString    mSafeURL;
  108. };
  109.  
  110.  
  111.  
  112. class nsXPITriggerInfo
  113. {
  114.   public:
  115.     nsXPITriggerInfo();
  116.     ~nsXPITriggerInfo();
  117.  
  118.     void                Add( nsXPITriggerItem *aItem ) 
  119.                         { if ( aItem ) mItems.AppendElement( (void*)aItem ); }
  120.  
  121.     nsXPITriggerItem*   Get( PRUint32 aIndex )
  122.                         { return (nsXPITriggerItem*)mItems.ElementAt(aIndex);}
  123.  
  124.     void                SaveCallback( JSContext *aCx, jsval aVal );
  125.  
  126.     PRUint32            Size() { return mItems.Count(); }
  127.  
  128.     void                SendStatus(const PRUnichar* URL, PRInt32 status);
  129.  
  130.     void                SetPrincipal(nsIPrincipal* aPrinc) { mPrincipal = aPrinc; }
  131.  
  132.  
  133.   private:
  134.     nsVoidArray mItems;
  135.     JSContext   *mCx;
  136.     nsCOMPtr<nsIXPConnectJSObjectHolder> mGlobalWrapper;
  137.     jsval       mCbval;
  138.     PRThread*   mThread;
  139.  
  140.     nsCOMPtr<nsIPrincipal>      mPrincipal;
  141.  
  142.     //-- prevent inadvertent copies and assignments
  143.     nsXPITriggerInfo& operator=(const nsXPITriggerInfo& rhs);
  144.     nsXPITriggerInfo(const nsXPITriggerInfo& rhs);
  145. };
  146.  
  147. #endif /* nsXPITriggerInfo_h */
  148.